Chapter 9
European vole populations follow the same damped oscillation as lab fruit flies and the relevant computer program.

Voles are simply adorable.
I am not saying that we should lie awake at night trembling at the thought of what voles might do to us.  Save that for the mechanism we pursue here; if you have followed this far, you know enough to be worried.  I don’t want to slander the cute little voles.  But look at this:

These are graphs of periodic field counts of European voles.  Counts on the vertical axis, time on the horizontal.
Fig. 31 11
In a number of places in Europe they have stations where they regularly count voles.  I can understand that it’s more fun to count voles than to count animals that are more dangerous or less cute.  While they have counted over the years the populations have gone up and down.  No problem there.  But they were meticulous enough to sum up their data and astute enough to notice a recurring pattern.  The pattern was damped oscillation. 
Again and again, they would see a population rise and fall in a cyclical pattern with each peak being somewhat lower than the one before.  I only copied three sequences, but they published more.  Since we have seen a pattern of damped oscillation in a captive population in the lab and in a computer simulation attempting to model an epigenetic (concerned with the control of genes rather than with the DNA sequence of genes) mechanism that links fertility with kinship through a post-zygotic process.
One point to notice is that in the lab and on the computer the peaks exhibit a rapid rise and slower fall of fertility.  I do not see that pattern in these wild European voles.  I suspect that the pattern has been obscured by statistical noise.  We are still on the trail of our quarry. In all my travels I have never seen this pattern in humans.  If I had to wave my hands, I’d say that human populations small enough to exhibit the same pattern simply are not conspicuous enough to turn up in the historical record.  As for what does turn up, we shall begin next time to follow the same sorts of counts … or at least a proxy for the same counts … among humans for just about all of history. 
We are done with thinking about the computer program for a while.  We shall return to it later, but in case your curiosity is peaked, below is the source code I wound up with.  If you do not do this kind of work, you are probably not familiar with reading source code, and if you do this kind of work you are probably not used to reading anybody else’s source code.  Such code is usually a closely guarded secret.  It has happened that a company will hire a programmer to produce a program.  Once the program is up and running the programmer resigns and becomes a consultant for maintaining it.  My low suspicious mind murmurs that the source code will contain spurious material making it extremely difficult for anyone else to understand.
However, the language I have used, C++, does make it possible to document what the major steps are.  There are two ways.  Anything written between slash star (/*) and star slash (*/) is a comment for the reader; the computer does not even read it.  Also, anything on a line that start with a double slash (//) is only a comment to explain what the computer is doing.  Again, the computer does not read it.  So given the source code, if it is well documented, you can just read the comments.  If you do it for this code, you will have read more about the inner workings than I can keep in my head.  If you want to use the code, of course you won’t want to enter it all manually.  Go to nobabies.net, scroll down to Summaries, open the first and the code will be there, toward the beginning of the entry, for you to copy and past into an appropriate compiler.  There may have been some changes made in C++ since I did this work; be warned.
So here goes – ultra secret source code documented and laid out for your interest. 
SOURCE CODE (Microsoft visual C++ 6.0)
/* This is a program to simulate the behavior of a population that is limited in size by
decreasing fertility with greater size and less kin members on average.  The program models
the genetic makeup of the population.  Genetic is to be understood in the broadest possible
sense to include epigenetic effects or any other inheritable factor.  This progam is named
"Accumulatign" for "Accumulating infertilty."
First we load our tools.*/
#include <iostream>
#include <iomanip>
#include <cmath> 
#include <cstdlib>
#include <fstream> 
#include <ctime>
using std::ios;
using std::ofstream;
using std::ifstream;
using std::cout;
using std::cin;
// Next the variables.
int RunNumber;
int MaxSims;
int Sims;
int MaxGens;
int Gens;
int MaxProgeny;
int OffspringComing;
int maxprogeny;
int InitPopSize;
int initpopsize;
int MaxPopSize;
int PopSize = 0;
int InNextGeneration;
long TopofHeap;
int Genes;
long GeneMutRate;
int PreZsites;
long PreZMutRate;
long PreZImpact;
int PostZsites;
long PostZMutRate;
long PostZImpact;
int AddFile;
int Incoming;
int incoming;
long ID;
long Arrow;
long Dart;
int slot;
int Mate;
long FickleFinger;
long Chance;
int Courting;
long coin;
long Coin;
int Lethal;
long Loss;
long MisMatch;
long mismatch;
long PreZInfertility;
long PostZInfertility;
int Delay;
int delay;
long AccumulatedInfertility;
int NotLastRun = 1;
int End;
//Then we establish the arrays.
long Population[1000][542];
long CurrentMate[542];
long OtherMate[542];
long Offspring[542];
long NextGeneration[100000][542];
int EndPopulations[101];
long FinalGenerations[100];
long PopHistory[1000000];
long main (long)
{//1 Main
// This is probably a good moment to start the random numbers.
srand(time(0));
// We let the user put his choices in.
RunNumber = 0;
cout << "\n What will be the number to identify this run?\n";
cin >> RunNumber;
            MaxSims = 101;
cout << "\n How many simulations do you want to run?  Don't go over 100. \n";
while (MaxSims > 100)
{//2 Choose MaxSims
cin >> MaxSims;
}//2 Choose MaxSims
            MaxGens = 1000001;
while (MaxGens > 1000000)
{//3 Choose MaxGens
cout << "\n Up to how many generations will each simulation last?\n";
cout << "\n Don't go over 1,000,000. No commas.\n";
cin >> MaxGens;
}//3 Choose MaxGens
            MaxProgeny = 201;
while(MaxProgeny>200)
{//4 Choose MaxProgeny
cout << "\n How many offspring maximum can one pair have? (200 is the maximum.)\n";
cin >> MaxProgeny;
}//4 Choose MaxProgeny
maxprogeny = MaxProgeny;
            InitPopSize = 1001;
while(InitPopSize>1000)
{//5 Choose InitPopSize
cout << "\n What size will your initial population be?  \n";
cout << "\n 100 would be a good start.\n Don't go over 1,000.  No comma.\n";
cin >> InitPopSize;
}//5 Choose InitPopSize
initpopsize = InitPopSize;
            MaxPopSize = 1001;
while(MaxPopSize>1000)
{//6 Choose MaxPopSize
cout << "\n What will your maximum population be?  Don't go over 1,000.  \n";
cout << "\n Don't use commas.\n";
cin >> MaxPopSize;
}//6 Choose MaxPopSize
            Genes = 51;
while(Genes > 50)
{//7 Choose Genes
cout << "\n How many gene pairs subject to recessive lethal mutations?  \n";
cout << "\n Don't go over 50.\n";
cin >> Genes;
}//7 Choose Genes
            GeneMutRate = 100001;
while(GeneMutRate > 100000)
{//8 Choose GeneMutRate
cout <<"\n How many genetic mutations per site per 100,000 generations?  \n";
cout << "\n Don't go over 100,000. \n";
cin >> GeneMutRate;
}//8 Choose GeneMutRate
            PreZsites = 101;
while(PreZsites > 100)
{//9 Choose PreZsites
cout << "\n How many sites will affect pre zygotic fertility?  \n";
cout << "\n Don't go over 100.\n";
cin >> PreZsites;
}//9 Choose PreZsites
            PreZMutRate = 100001;
while(PreZMutRate > 100000)
{//10 Choose PreZMutRate
cout << "\n What change rate per site per 100,000 generations?  \n";
cout << "\n Don't go over 100,000.\n";
cin >> PreZMutRate;
}//10 Choose PreZMutRate
            PreZImpact = 100001;
while(PreZImpact > 100000)
{//11 Choose PreZImpact
cout << "\n How many thousandths of 1 offspring will a unit of mismatch result \n";
cout << "\n in losing.  500 would have a 50% chance of losing one. \n";
cout << "\n Don't go over 100,000.\n";
cin >> PreZImpact;
}//11 Choose PreZImpact

PostZsites = 101;
while(PostZsites > 100)
{//12 Choose PostZsites
cout << "\n How many sites will affect post zygotic fertility?  \n";
cout << "\n Don't go over 100.\n";
cin >> PostZsites;
}//12 Choose PostZsites
            PostZMutRate = 100001;
while(PostZMutRate > 100000)
{//13 Choose PostZMutRate
cout << "\n What change rate per site per 100,000 generations?  \n";
cout << "\n Don't go over 100,000.\n";
cin >> PostZMutRate;
}//13 Choose PostZMutRate
            PostZImpact = 100001;
while(PostZImpact > 100000)
{//14 Choose PostZImpact
cout << "\n How many thousandths of 1 offspring will a unit of mismatch result\n";
cout << "\n in losing.  500 would have a 50% chance of losing one. \n";
cout << "\n Don't go over 100,000.\n";
cin >> PostZImpact;
}//14 Choose PostZImpact
            Delay = 21;
while(Delay > 20)
{//102 Choose Delay
cout << "\n The program will let post zygotic infertilty accumulate for up to 20\n";
cout << "\n generations.  Choose at least 1 for any effect.  Don't go over 20.\n";
cin >> Delay;
}//102 Choose Delay
            AddFile = 0;
cout << "\n As the program runs, the screen will print out the number of offspring\n";
cout << "\n each generation.  Do you wish to add a file? 1 for yes, 0 for no.  \n";
cout << "\n Don't add more than are saved  or more than there is room for. \n";
cin >> AddFile;
if(AddFile == 1)
{//15a Add file
cout << " How many?  File should be saved on drive C as InPop.\n";
cin >> Incoming;
}//15a Add file
else
{//15b Add no file
}//15b Add no file
            cout << "\n";
            //We start running the simulations.
Sims = 1;
while(Sims<=MaxSims)
{//Begin Sims.//16 Sims
if(ID>1000000) //We make sure not to overrun ID.
{//17a Reset ID
ID = 0;
}//17a Reset ID
else
{//17b Don't reset ID
}//17b Don't reset ID
//We create a population.
PopSize = 0;
while(PopSize < InitPopSize)
{//Begin create population.//18 Create population
Population[PopSize][0] = ID;
ID = ID + 1;
Population[PopSize][1] = 0;
Arrow = 541;
while(Arrow >= 1)
{//19 Zero out array
Population[PopSize][Arrow] = 0;
Arrow = Arrow - 1;
}//19 Zero out array
PopSize = PopSize + 1;
}//End create population.//18 Create population
                        //We import a population.
if(AddFile == 1)
{// Begin import files. //20a Import population
incoming = Incoming;
ifstream File("C:\\InPop", ios:: in);
while(incoming > 0)
{//21 Importing
Arrow = 0;
while(Arrow<=541)
{//22 Copy one
File >> slot;
Population[PopSize][Arrow] = slot;
Arrow = Arrow + 1;
}//22 Copy one
Population[0][PopSize] = ID;
ID = ID + 1;
PopSize = PopSize + 1;
incoming = incoming - 1;
}//21 Importing
File.close();
}// End import files.//20a Import population
                        else //We do not import from a file.
{//20b Don't import
}//20b Don't import
                        //Begin running generations.
Gens = 1;
while(Gens <= MaxGens)
{//Begin Generations.//23 Gens
Mate = 0;
InNextGeneration = 0;
while(PopSize > 1)
{//Begin running the population.//24 Run pop
if (Mate == 0)
{//Begin find mates.//25a Find mates
                                                            //We take the first mate.
Arrow = 541;
while(Arrow>=0)
{//Begin copy current mate.//26 Copy current mate
TopofHeap = PopSize - 1;
CurrentMate[Arrow] = Population[TopofHeap][Arrow];
Arrow = Arrow - 1;
}//End copy current mate.//26 Copy current mate
  //We take another mate from what is left.
TopofHeap = TopofHeap - 1;
if(TopofHeap == 0)
{//27a Out of mates
Courting = 0;
}//27a Out of mates
else
{//27b Find a mate
TopofHeap = TopofHeap + 1;
FickleFinger = rand()*rand();
Courting = FickleFinger % TopofHeap;
}//27b Find a mate
Arrow = 541;
while(Arrow>=0)
{//Begin copy other mate.//28 Copy other mate
OtherMate[Arrow] = Population[Courting][Arrow];
//Fill the place where other mate was.
Population[Courting][Arrow] = Population[TopofHeap][Arrow];
 Arrow = Arrow - 1;
}//End copy other mate.//28 Copy other mate
Mate = 1;
}//End find mates.//25a Find Mates
else
{//Begin make many offspring.//25b Make many offspring
OffspringComing = MaxProgeny;//We allow for infertility starting
//with pre zygotic.
//We calculate pre zygotic infertility.
if (PreZsites> 0 )
{//29a PreZsites > 0
Arrow = 50 + PreZsites;
Dart = 320 + PreZsites;
MisMatch = 0;
mismatch = 0;
while(Arrow > 100)                             
{//30 Count PreZsites
mismatch = Offspring[Arrow] - Offspring[Dart] ;
if(mismatch < 0)                                   
{//31a Change to positive
mismatch = mismatch * -1;
}//31a Change to positive
else
{//31b Leave positive
}//31b Leave positive
MisMatch = MisMatch + mismatch;
mismatch = 0;
Arrow = Arrow - 1;
Dart = Dart - 1;
}//30 Count PreZsites
PreZInfertility = 0;
Loss = PreZImpact * MisMatch;
if(Loss >= 1000)
{//32a Lower fertility one offspring at a time
while(Loss >= 1000)
{//33
PreZInfertility = PreZInfertility +1;
Loss = Loss - 1000;
}//33
}//32a Lower fertility one offspring at a time
else
{//32b No whole offspring lost
}//32b No whole offspring lost
coin = rand();
Coin = coin % 1000;
if(Loss > Coin)
{//34a Lose fractional offspring
PreZInfertility = PreZInfertility + 1;
}//34a Lose fractional offspring
else
{//34bKeep fractional offspring
}//34b Keep fractional offspring
OffspringComing = OffspringComing - PreZInfertility;
}//29a PreZsites > 0
else
{//29b PreZsites = 0
}//29b PreZsites = 0
//Then we take out the post zygotic infertility of each parent.OffspringComing = OffspringComing - CurrentMate[541];
OffspringComing = OffspringComing - OtherMate[541];
if(OffspringComing >0)
{//35a If making offspring
while(OffspringComing > 0)
{//Make one offspring. //36Make one offspring
Offspring[0] = ID;
ID = ID + 1;
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//Begin copy one chromosome.//37a Copy one chromosome
Arrow = 270;
while(Arrow > 0)
{//38 Copy
Offspring[Arrow] = CurrentMate[Arrow];
Arrow = Arrow - 1;
}//38  Copy
}//37a Copy one chromosome
else
{//37b Copy other chromosome
Arrow = 270;
Dart = 540;
while(Arrow > 0)
{//39 Copy
Offspring[Arrow] = CurrentMate[Dart];
Arrow = Arrow - 1;
Dart = Dart - 1;
}//39 Copy
}//End copy one chromosome.//37b Copy other chromosome
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//Begin copy second chromosome//40a Copy second chromosome
Arrow = 540;
while(Arrow > 270)
{//41 Copy
Offspring[Arrow] = OtherMate[Arrow];
Arrow = Arrow - 1;
}//41 Copy
}//40a Copy second chromosome
else
{//40b Copy other second
Arrow = 540;
Dart = 540;
while(Arrow > 270)
{//42 Copy
Offspring[Arrow] = OtherMate[Dart];
Arrow = Arrow - 1;
Dart = Dart -1;
}//42 Copy
}//End copy second chromosome.40b Copy other second

//We check to see if there are matched recessive lethals.
Arrow = 50;
Dart = 320;
Lethal = 0;
while(Arrow > 0)
{//Check for lethal.//43 Check for lethal
if(Offspring[Arrow] + Offspring[Dart] > 1)
{//44a Lethal
Lethal = 1;
}//44a Lethal
else
{//44b Not Lethal
}//44b Not Lethal
Arrow = Arrow - 1;
Dart = Dart - 1;
}//43 Check for lethal
if(Lethal == 1)
{//45a Lose one offspring
OffspringComing = OffspringComing - 1;
}//End check for lethal//45a Lose one offspring.
else
{ //We continue .//45b Continue with offspring
OffspringComing = OffspringComing -1;

//We mutate the genes.
if(GeneMutRate > 0)//Begin mutate genes.
{//46a Mutate Genes
Arrow = 0 + Genes;
while(Arrow > 0)
{//47 Mutate one
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(GeneMutRate > Chance)
{//48a change
Offspring[Arrow] = 1;
}//48a change
else
{//48b Don't change
}//48b// Don't change
Arrow = Arrow - 1;
}//47 Mutate one         
Arrow = 270 + Genes;
while(Arrow > 270)
{// 49 Mutate other
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(GeneMutRate > Chance)
{//50a Change 
Offspring[Arrow] = 1;
}//50a Change
else
{//50b Don't change
}//50b Don't change
Arrow = Arrow -1;
}// 49 Mutate other
}//46a Mutate Genes
else
{//46b Don't mutate Genes                                                                                                       
}//End mutate // genes.//46b Don't mutate Genes
//We mutate the PreZsites.
if(PreZsites > 0)
{//Begin mutate PreZsites. //51a Mutate PreZsites
Arrow = 50 + PreZsites;
while(Arrow>50)//Mutate first PreZsites segment.
{//52 Count PreZsites one
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PreZMutRate > Chance)
{//53a Change
coin = rand();
Coin = coin % 2;
if(Coin = 1)
{//54a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//54a Increase
else
{//54b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//54b Decrease
}//53a Change
else
{//53b Don't change
}//53b Don't change
Arrow = Arrow - 1;
}//52 Count PreZsites one

Arrow = 320 +PreZsites;
while(Arrow>320)//Mutate other PreZsites segment.  
{//55 Count PreZsites two
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PreZMutRate > Chance)
{//56a Change
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//57a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//57a Increase
else
{//57b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//57b Decrease
}//56a Change
else
{//56b Don't change
}//56b Don't change
Arrow = Arrow - 1;
}//55 Count PreZsites two
}//51a Mutate PreZsites
else
{//51b Don't mutate PreZsites
}//51b Don't mutate PreZsites

//End mutate PreZsites.
 //We mutate the PostZsites.
if(PostZsites > 0)
{//Begin mutate PostZsites.//58a Mutate PostZsites
Arrow = 150 + PostZsites;
while(Arrow>150)//Mutate first PostZsites segment.
{//59 Count PostZsites one
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PostZMutRate > Chance)
{//60a Change
coin = rand();
Coin = coin % 2;
if(Coin = 1)
{//61a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//61a Increase
else
{//61b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//61b Decrease
}//60a Change
else
{//60a Don't change
}//60a Don't change
Arrow = Arrow - 1;
}//59 Count PostZsites one

Arrow = 420 +PostZsites;
while(Arrow>420)//Mutate other PostZsites segment.
{//62 Count PostZsites two
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PostZMutRate > Chance)
{//63a Change
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//64a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//64a Increase
else
{//64b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//64b Decrease
}//63a Count PostZsites two
else
{//63b Don't change
}//63b Don't change
Arrow = Arrow - 1;
}//62 Count PostZsites two
}//58a Mutate PostZsites
else
{//58b Don't mutate PostZsites
}//58b Don't mutate PostZsites

//End mutate PostZsites.
if (PostZsites >0)//We calculate post zygotic
//infertility.
{Arrow = 150 + PostZsites;//65a Use PostZsites
Dart = 420 + PostZsites;
MisMatch = 0;
mismatch = 0;
while(Arrow > 150)
{//66 Count PostZsites
mismatch = Offspring[Arrow] - Offspring[Dart] ;
if(mismatch < 0)
{//67a Change to positive
mismatch = mismatch * -1;
}//67a Change to positive
else
{//67b Leave positive
}//67b Leave postive
MisMatch = MisMatch + mismatch;
mismatch = 0;
Arrow = Arrow - 1;
Dart = Dart - 1;
}//66 Count PostZsites
PostZInfertility = 0;
Loss = PostZImpact * MisMatch;
if(Loss > 1000)
{//68a Lose whole offspring
while(Loss > 1000)
{//69 Lose one
PostZInfertility = PostZInfertility +1;
Loss = Loss - 1000;
}//69 Lose one
}//68a Lose whole offspring
else
{//68b No whole offspring lost
}//68b No whole offspring lost
coin = rand();
Coin = coin % 1000;
if(Loss > Coin)
{//70a Lose fractional offspring
PostZInfertility = PostZInfertility + 1;
}//70a Lose fractional offspring
else
{//70b Keep fractional offspring
}//70b Keep fractional offspring
Arrow = 251;
Dart = 252;
while (Arrow < 270)
{//103 Shuffle in post zygotic infertility
Offspring[Arrow] = Offspring[Dart];
Arrow = Arrow + 1;
Dart = Dart + 1;
}//103 Shuffle in post zytotic infertility
Offspring[270] = PostZInfertility;// Top off this chromosome
Arrow = 521;
Dart = 522;
while (Arrow < 540)
{//103 Shuffle in post zygotic infertility
Offspring[Arrow] = Offspring[Dart];
Arrow = Arrow + 1;
Dart = Dart + 1;
}//103 Shuffle in post zytotic infertilty
Offspring[540] = PostZInfertility;// Top off this other chromosome
//Add up delayed infertiltiy.
AccumulatedInfertility = 0;
delay = Delay;
Arrow = 271 - Delay;
while (Arrow < 271)
{//104//Count 1 chromosome
AccumulatedInfertility = AccumulatedInfertility = Offspring[Arrow];
Arrow = Arrow + 1;
}//104//Count 1 chromosome
Arrow = 541 - Delay;
while (Arrow < 541)
{//105//Count other chromosome
AccumulatedInfertility = AccumulatedInfertility = Offspring[Arrow];
Arrow = Arrow + 1;
}//105//Count other chromosome
Offspring[541] = AccumulatedInfertility;//And put it in its place
}//65a Use PostZsites
else
{//65b Don't use PostZsites
}//65b Don't use PostZsites
//Transfer offspring to next generation.
Arrow = 541;
while(Arrow>=0)
{//71 Transfer offspring
NextGeneration[InNextGeneration][Arrow] = Offspring[Arrow];
Arrow = Arrow - 1;
}//71 Transfer offspring
InNextGeneration = InNextGeneration + 1;
}//45b Continue with offspring

}//36 Make one offspring
Mate = 0;
PopSize = PopSize - 2;
}//35a If making offspring
else
{//35b Finish making offspring
Mate = 0;
PopSize = PopSize - 2;
}//35b Finish making offspring
}//End make many offspring.//25b Make many offspring
}//End running the population. //24 Run pop 
cout << InNextGeneration << " ";//We report total offspring this
//generation to screen and array.
PopHistory[Gens] = InNextGeneration;//72 Write to array
if(Gens==MaxGens)
{//73a Record last PopSize and Gens run
NotLastRun = 0;//We stop recording offspring to the array.
EndPopulations[Sims] = InNextGeneration;
//We record last offsping and
//last generation number for this simulation.
FinalGenerations[Sims] = Gens;
}//73a Record last PopSize and Gens run
else
{//73b Not yet
}//73b Not yet
//We transfer the new population.
if(InNextGeneration <2)//We see if the population has crashed.
{//74a If pop crashed prepare to shut down.
FinalGenerations[Sims] = Gens;
Gens = MaxGens;
}//74a If pop crashed prepare to shut down.
else
{//We prepare for a new cycle.//74b Prepare new cycle.
if(InNextGeneration <= MaxPopSize)//We transfer all of the population.
{//75a Transfer whole pop
Dart = InNextGeneration - 1;
PopSize = 0;
while(Dart >= 0)
{//76 Count down pop
Arrow = 541;
while(Arrow >= 0)
{//77 Transfer
Population[PopSize][Arrow] = NextGeneration [Dart][Arrow];
Arrow = Arrow - 1;
}//77 Transfer
PopSize = PopSize + 1;
Dart = Dart - 1;
}//76 Count down pop
}//75a Transfer whole pop
else//We transfer some of the population.
{//75b Transfer some pop
PopSize = 0;
TopofHeap = InNextGeneration - 1;
while(PopSize < MaxPopSize)
{//78 Count down pop
Arrow = 541;
FickleFinger = rand() * rand();
Dart = FickleFinger % InNextGeneration;
while (Arrow >= 0)
{//79 Transfer
Population[PopSize][Arrow] = NextGeneration[Dart][Arrow];
NextGeneration[Dart][Arrow] = NextGeneration[TopofHeap][Arrow];
Arrow = Arrow - 1;
}//79 Transfer
PopSize = PopSize +1;
TopofHeap = TopofHeap -1;
}//78 Count down pop
}//75b Transfer some pop
}//74b Prepare new cycle.                                                                   
Gens = Gens +1;
}//End Generations. //23 Gens
cout << " Simulation " << Sims << " done. \n";
Sims = Sims + 1;
}//End Sims. //16 Sims             
cout << "\n The final populations in the simulations were: ";
Arrow = 1;
while(Arrow <= MaxSims)
{//80 Print final pop to screen
cout << EndPopulations[Arrow] << " ";
Arrow = Arrow + 1;
}//80 Print final pop to screen
cout << "\n\n The number of generations run in the simulations were: ";
Arrow = 1;
while(Arrow <= MaxSims)
{//81 Print gens each Sim to screen
cout << FinalGenerations[Arrow] << " ";
Arrow = Arrow + 1;
}//81 Print gens each Sim to screen
ofstream Summary("C:\\Summary",ios :: out);
Summary << "Summary \n\n The run number was " << RunNumber
<< ".  The number of Simulations was " << MaxSims
<< ".  The parameters were: Maximum generations "
<< MaxGens << " . Maximum offspring " << MaxProgeny << ".  Initial population "
<< InitPopSize << ". Maximum Population " << MaxPopSize
<< ".  Number of gene pairs subject to recessive lethal mutations "
<< Genes << ".  Mutation rate of the genes " << GeneMutRate
<< ".  Number of sites affecting pre zygotic fertility was " << PreZsites
<< ".  Change rate at each site was " << PreZMutRate
<< " per site per 100,000 generations.  Number of thousandths of an offspring "
<< "lost per unit of mismatch was " << PreZImpact
<< ".  Number of sites affecting post zygotic fertility was "  << PostZsites
<< ".  Change rate for the sites affect post zygotic fertility was "
<< PostZMutRate << " per site per 100,000 generations.  "
<< "The number of thousandths of offspring lost per unit of mismatch was "
<< PostZImpact << ".  Infertility accumulated for " << Delay
<< " generations.  A file was added. (1 for yes, 0 for no.) "  << AddFile
<< ".\n\n  The offspring in the final population(s) of the(each) "
<< "simulation was(were): ";
Arrow = 1;
while(Arrow <= MaxSims)
{//82 Send final pops to summary
slot = EndPopulations[Arrow];
Summary << slot << " ";
Arrow = Arrow + 1;
}//82 Send final pops to summary
Summary << ".\n\n The generation(s) run by the(each) simulation was(were): ";
Arrow = 1;
while(Arrow <= MaxSims)
{//83 Send final Gens per Sim to summary
slot = FinalGenerations[Arrow];
Summary << slot  << " ";
Arrow = Arrow + 1;
}//83 Send final Gens per Sim to summary
Summary << "\n\n The numbers of offspring in each generation of the last simulation"
<<" were: ";
Arrow = 1;
while(Arrow <= MaxGens)
{//Send offpring each Gen in last Sim
slot = PopHistory[Arrow];
Summary << slot << " ";
Arrow = Arrow + 1;
}//Send offpring each Gen in last Sim
Summary.close();
cout << "\n\n The program will save a summary of the run as Summary.  It is also "
<< "able to save your remaining population as RemainingPop.  Files are saved "
<< "on drive C. \n Do you wish to save a population?  1 for yes, 0 for no.\n";
cin >> Coin;
if(Coin == 0)
{//85a No pop saved
}//85a No pop saved
else
{//85b Save a population
cout << " How many do you want to save?  Don't go over " << PopSize << ".\n";
cin >> Incoming;
ofstream OutFile("C:\\RemainingPop",ios :: out);
Dart = Incoming - 1;
Arrow = 0;
while(Dart >= 0)
{//86 Count down members
while(Arrow <= 541)
{//87 Count one member
slot = NextGeneration[Dart][Arrow];
OutFile << slot << " ";
Arrow = Arrow + 1;
}//87 Count one member
Dart = Dart - 1;
Arrow = 0;
}//86 Count down members
OutFile.close();
cout << "\n\n The key to reading Remaining Pop is:the first number is generally "
<< "a very large one and is the ID number for that individual.  Then 2 "
<< "through 51 are genes on the first chromosome; 52 through 151 pre "
<< "zygotic sites on that chromosome.  152 through 251 post zygotic sites; "
<< "252 through 271are the accumulating generations of infertilty on that "
<< "chromosome and then 272 - 321 genes, 322 - 421 pre, 422 -  521 post, 522 - 541 "
<< "accumulating infertilty on the other.  542 is post zygotic infertilty. /n/n";
}//85b Save a population
cout << "\n Enter any number to finish. \n";
cin >> End;
return 0;
}//1 Main

Chapter 10

Table of contents

Home page